import 'dart:convert';

class MusicQueryBean {
  MusicQueryBean({
    required this.cursor,
    required this.data,
    required this.err,
    required this.errMsg,
    required this.token,
  });

  late final int cursor;
  late final MusicBoxs data;
  late final int err;
  late final String errMsg;
  late final String token;

  static MusicQueryBean getEmptyBean() {
    return MusicQueryBean(
        cursor: 0,
        data: MusicBoxs.getEmptyBean(),
        err:0,
        errMsg:"",
        token:"",
    );
  }



  MusicQueryBean.fromJson(Map<String, dynamic> json) {
    cursor = json['cursor'];
    data = MusicBoxs.fromJson(json['data']);
    err = json['err'];
    errMsg = json['err_msg'];
    token = json['token'];
  }

  Map<String, dynamic> toJson() {
    final _data = <String, dynamic>{};
    _data['cursor'] = cursor;
    _data['data'] = data.toJson();
    _data['err'] = err;
    _data['err_msg'] = errMsg;
    _data['token'] = token;
    return _data;
  }
}

class MusicBoxs {
  MusicBoxs({
    required this.boxs,
  });

  late final List<MusicBox> boxs;


  static MusicBoxs getEmptyBean() {
    return MusicBoxs(
      boxs: [],
    );
  }

  MusicBoxs.fromJson(Map<String, dynamic> json) {
    boxs = List.from(json['boxs']).map((e) => MusicBox.fromJson(e)).toList();
  }

  Map<String, dynamic> toJson() {
    final _data = <String, dynamic>{};
    _data['boxs'] = boxs.map((e) => e.toJson()).toList();
    return _data;
  }
}

class MusicBox {
  MusicBox({
    required this.folderName,
    required this.musics,
  });

  late final String folderName;
  late final List<Music> musics;

  MusicBox.fromJson(Map<String, dynamic> json) {
    folderName = json['folder_name'];
    musics = List.from(json['musics']).map((e) => Music.fromJson(e)).toList();
  }

  Map<String, dynamic> toJson() {
    final _data = <String, dynamic>{};
    _data['folder_name'] = folderName;
    _data['musics'] = musics.map((e) => e.toJson()).toList();
    return _data;
  }
}

class Music {
  Music({
    required this.key,
    required this.name,
    required this.title,
    required this.artist,
    required this.duration,
    required this.uploader,
    required this.desc,
    required this.uploadTime,
    required this.url,
    required this.imgUrl,
  });

  late final String key;
  late final String name;
  late final String title;
  late final String artist;
  late final int duration;
  late final String uploader;
  late final String desc;
  late final int uploadTime;
  late final String url;
  late final String imgUrl;

  static Music getEmptyBean() {
    return Music(
      key: "",
      name: "",
      title: "",
      artist: "",
      duration: 0,
      uploader: "",
      desc: "",
      uploadTime: 0,
      url: "",
      imgUrl: "",
    );
  }

  Music.fromJson(Map<String, dynamic> json) {
    key = json['key'];
    name = json['name'];
    title = json['title'];
    artist = json['artist'];
    duration = json['duration'];
    uploader = json['uploader'];
    desc = json['desc'];
    uploadTime = json['upload_time'];
    url = json['url'];
    imgUrl = json['img_url'];
  }

  Map<String, dynamic> toJson() {
    final _data = <String, dynamic>{};
    _data['key'] = key;
    _data['name'] = name;
    _data['title'] = title;
    _data['artist'] = artist;
    _data['duration'] = duration;
    _data['uploader'] = uploader;
    _data['desc'] = desc;
    _data['upload_time'] = uploadTime;
    _data['url'] = url;
    _data['img_url'] = imgUrl;
    return _data;
  }
}
